package com.mic.security.service;

import java.util.List;
import java.util.UUID;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.mic.security.dao.UserDAO;
import com.mic.security.model.User;

@Service("userService")
public class UserServiceImpl implements UserService{

	@Autowired
	private UserDAO userDAO;
	
	@Override
	public User findUserById(String id) {
		return userDAO.findUserById(id);
	}

	@Override
	public User findUserByUsername(String username) {
		return userDAO.findUserByUsername(username);
	}


	@Override
	public List<User> findAllUsers() {
		return userDAO.findAllUser();
	}

	@Override
	public void saveUser(User user) {
		user.setId(UUID.randomUUID().toString());
		userDAO.saveUser(user);
	}

	@Override
	public void updateUser(User user) {
		userDAO.updateUser(user);
	}

	@Override
	public void deleteUserById(String id) {
		userDAO.deleteUserById(id);
	}

	public UserDAO getUserDAO() {
		return userDAO;
	}

	public void setUserDAO(UserDAO userDAO) {
		this.userDAO = userDAO;
	}

}
